package com.smartproxy.net;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

import com.smartproxy.utils.SPConstants;

public class SPServer {

	public SPServer() {
		
	}
	
	public void listen() {
		try {
			ServerSocket ss = new ServerSocket( SPConstants.LOCAL_PORT );
		
			while( true ) {
				Socket client = ss.accept();
				Socket server = new Socket( SPConstants.REMOTE_SERVER, SPConstants.REMOTE_PORT );
				
				new SPConnectionHandler( client, server );
				new SPConnectionHandler( server, client );
			}
		} catch (IOException e) {
			System.out.println( "Cannot initialize the server" );
		}
	}
}
